(*
 * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
 *
 * SPDX-License-Identifier: BSD-2-Clause
 *)

chapter Lib

session Lib (lib) = Word_Lib +
  sessions
    "HOL-Library"
    "HOL-Eisbach"
  directories
    "ml-helpers"
    "subgoal_focus"
    "Monad_WP"
    "Monad_WP/wp"
  theories
    Lib
    Apply_Trace_Cmd
    AddUpdSimps
    EmptyFailLib
    List_Lib
    SubMonadLib
    Simulation
    MonadEq
    SimpStrategy
    Extract_Conjunct
    GenericLib
    ProvePart
    Corres_Adjust_Preconds
    Requalify
    Value_Abbreviation
    Eisbach_Methods
    HaskellLib_H
    Eval_Bool
    Bisim_UL
    Extend_Locale
    Solves_Tac
    Crunch
    Crunch_Instances_NonDet
    Crunch_Instances_Trace
    StateMonad
    Corres_UL
    Find_Names
    LemmaBucket
    Try_Methods
    ListLibLemmas
    Time_Methods_Cmd
    Apply_Debug
    MonadicRewrite
    HaskellLemmaBucket
    "ml-helpers/MkTermAntiquote"
    "ml-helpers/TermPatternAntiquote"
    "ml-helpers/TacticAntiquotation"
    "ml-helpers/MLUtils"
    "ml-helpers/TacticTutorial"
    "ml-helpers/MkTermAntiquote_Tests"
    "ml-helpers/TacticAntiquotation_Test"
    "ml-helpers/TermPatternAntiquote_Tests"
    FP_Eval
    "subgoal_focus/Subgoal_Methods"
    Insulin
    ExtraCorres
    NICTATools
    BCorres_UL
    Qualify
    LexordList
    Rule_By_Method
    Defs
    AutoLevity_Hooks
    Distinct_Cmd
    Match_Abbreviation
    ShowTypes
    SpecValid_R
    EquivValid
    SplitRule
    DataMap
    FastMap
    RangeMap
    Corres_Method
    Conjuncts
    DetWPLib
    Guess_ExI
    GenericTag
    ML_Goal_Test

    (* should really be a separate session, but too entangled atm: *)
    NonDetMonadLemmaBucket
    "Monad_WP/WhileLoopRules"
    "Monad_WP/TraceMonad"
    "Monad_WP/OptionMonadND"
    "Monad_WP/OptionMonadWP"
    "Monad_WP/Strengthen_Demo"
    "Monad_WP/TraceMonadLemmas"
    "Monad_WP/wp/WPBang"
    "Monad_WP/wp/WPFix"
    "Monad_WP/wp/Eisbach_WP"
    "Monad_WP/wp/WPI"
    "Monad_WP/wp/WPC"
    "Monad_WP/wp/WPEx"
    "Monad_WP/wp/WP_Pre"
    "Monad_WP/wp/WP"
    "Monad_WP/Datatype_Schematic"
    "Monad_WP/WhileLoopRulesCompleteness"
    "Monad_WP/Strengthen"
    "Monad_WP/OptionMonad"
    "Monad_WP/TraceMonadVCG"
    "Monad_WP/NonDetMonadVCG"
    "Monad_WP/NonDetMonad"
    "Monad_WP/NonDetMonadLemmas"

session CLib (lib) in clib = CParser +
  sessions
    "HOL-Library"
    "HOL-Statespace"
    "HOL-Eisbach"
    "Simpl-VCG"
    Lib
  theories
    Corres_UL_C
    CCorresLemmas
    CCorres_Rewrite
    Simpl_Rewrite
    MonadicRewrite_C
    CTranslationNICTA
    LemmaBucket_C
    SIMPL_Lemmas
    SimplRewrite
    TypHeapLib
    BitFieldProofsLib
    XPres

session CorresK in "CorresK" = Lib +
  sessions
    ASpec
    ExecSpec
  theories
    CorresK_Lemmas

session LibTest (lib) in test = Refine +
  sessions
    Lib
    CLib
    ASpec
    ExecSpec
  theories
    Crunch_Test_NonDet
    Crunch_Test_Qualified_NonDet
    Crunch_Test_Qualified_Trace
    Crunch_Test_Trace
    WPTutorial
    Match_Abbreviation_Test
    Apply_Debug_Test
    AutoLevity_Test
    Insulin_Test
    ShowTypes_Test
    Time_Methods_Cmd_Test
    FastMap_Test
    RangeMap_Test
    FP_Eval_Tests
    Trace_Schematic_Insts_Test
    Local_Method_Tests
    Qualify_Test
    Locale_Abbrev_Test
  (* use virtual memory function as an example, only makes sense on ARM: *)
  theories [condition = "L4V_ARCH_IS_ARM"]
    Corres_Test

session SepTactics (lib) in Hoare_Sep_Tactics = Sep_Algebra +
  theories
    Hoare_Sep_Tactics

(* bitrotted
session AutoLevity (lib) = HOL +
  theories
    AutoLevity
    AutoLevity_Run
    AutoLevity_Theory_Report
*)

session Concurrency (lib) in concurrency = HOL +
  sessions
    Lib
  directories
    "examples"
  theories
    Atomicity_Lib
    Triv_Refinement
    Prefix_Refinement
    "examples/Peterson_Atomicity"
    "examples/Plus2_Prefix"
